package BasicTypes;

import java.util.StringTokenizer;

public class Position {
	public int x = 0;
	public int y = 0;
	
	public Position(int x , int y){
		this.x = x;
		this.y = y;
	}
	
	public Position(int p){
		this.x = p/Constants.SIZE;
		this.y = p%Constants.SIZE;
	}
	
	public boolean equals(Position p){
		if(this.x == p.x && this.y == p.y){
			return true;
		}
		return false;
	}
	
	public Position(){
		x = 0;
		y = 0;
	}
	
	public Position(String str){
		StringTokenizer st = new StringTokenizer(str,"_");
		x = Integer.parseInt(st.nextToken());
		y = Integer.parseInt(st.nextToken());
	}
	
	public String getString(){
		return Integer.toString(x) + "_" + Integer.toString(y) + "_";
	}
	
	public int toNumber(){
		return x * Constants.SIZE + y;
	}
	
}
